<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<style>

    .red{
        background-color: red;
    }
    .yellow{
        background-color: yellow;
    }
</style>

<body>
    
    <div id="box">

        <div style="background: yellow;">1111</div>
        <button @click="handleClick()">click</button>
        <div :class="isActive?'red':'yellow'">我是动态绑定class的写法</div>

    </div>
    
    
    <script>
        var vm = new Vue({
            el: "#box",
            data: {
                isActive: true,
            },
            methods:{
                handleClick(){
                    this.isActive = !this.isActive
                }
            }
        })
    </script>

</body>
</html>